package com.example.controller;


import com.example.entity.Authentication;
import com.example.entity.Legalperson;
import com.example.service.IAuthenticationService;
import com.example.util.Code;
import com.example.util.Result;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tyhxzy
 * @since 2023-11-03
 */
@RestController
@RequestMapping("/s/authentication")
public class AuthenticationController {
    @Autowired
    IAuthenticationService service;

    //根据zid即商户id查询对应的各项认证
    @GetMapping("/rz/{id}")
    public Result RZ(@PathVariable Integer id){
        Authentication select = service.select(id);
        if (select!=null){
            return new  Result(Code.GET_OK,select,"查询成功");
        }
        return new Result(Code.GET_ERR,"查询失败");
    }
    //查询认证状态
    @GetMapping("/map/{id}")
    public Result findMap(@PathVariable Integer id){
        return new Result(Code.GET_OK,service.findZt(id),"查询成功") ;
    }

    //将状态改为0
    @RequestMapping("/updateStatus/{zid}")
    public Result updateStatus(@PathVariable Integer zid){
        int i = service.updateStatus(zid);
        if (i>0){
            return new Result(Code.UPDATE_OK,"审核通过");
        }else {
            return new Result(Code.UPDATE_ERR,"审核不通过");
        }
    }

    //将状态改为1
    @RequestMapping("/updateStatus1")
    public Result updateStatus1(@RequestBody Legalperson legalperson){
        int i = service.updateStatus1(legalperson);
        if (i>0){
            return new Result(Code.UPDATE_ERR,"审核不通过");
        }else {
            return new Result(Code.UPDATE_OK,"审核不通过");
        }
    }
}
